<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>显示-隐藏</title>
</head>
<body>

<div id="box">
    我在这里！
</div>
<button id="btnToggle">toggle</button>
</body>
<script>

    var box = document.getElementById('box');
    var btnToggle = document.getElementById('btnToggle');
    var isShow = true;


    btnToggle.onclick = function () {
        if (isShow) {
            box.style.display = 'none';
            isShow = false;
        } else {
            box.style.display = 'block';
            isShow = true;
        }

    }


</script>
</html>